package org.example.d8_stream;

import java.util.*;
import java.util.stream.Stream;

public class StreamTest2 {
    public static void main(String[] args) {
        //1.如何获取List集合的Stream流？
        List<String> names = new ArrayList<>();
        Collections.addAll(names,"张三丰","张无忌","周涵","张强");
        Stream<String> stream = names.stream();

        //2.如何获取set集合的Stream流？
        Set<String> set = new HashSet<>();
        Collections.addAll(set,"刘德华","张曼玉","蜘蛛精","马德","德玛西亚");
        Stream<String> stream1 = set.stream();
        stream1.filter(s -> s.startsWith("德")).forEach(s -> System.out.println(s));

        //3.如何获取map集合的stream流
        Map<String,Double> map = new HashMap<>();
        map.put("迪丽热巴",168.5);
        map.put("古力娜扎",153.5);
        map.put("马尔扎巴",165.6);
        map.put("哈哈艾哈",188.5);

        Set<String> keys = map.keySet();
        Stream<String> ks = keys.stream();

        Collection<Double> values = map.values();
        Stream<Double> vs = values.stream();

        Set<Map.Entry<String, Double>> entries = map.entrySet();
        Stream<Map.Entry<String, Double>> kvs = entries.stream();
        kvs.filter(e->e.getKey().contains("巴"))
                .forEach(e-> System.out.println(e.getKey() + "----->" +e.getValue()));

            //4.如何获取数组的Stream流
        String[] names2 = {"张赞","李四","翠花","小花"};
        Stream<String> s1 = Arrays.stream(names2);
        Stream<String> s2 = Stream.of(names2);

    }
}
